Skip to main content

Distance-Based Ramping

The BasicMotion_CamIn_StartModes.project sample project described here is located in the installation directory of CODESYS under the ..\CODESYS SoftMotion\Examples directory.

This example shows how to use the StartMode input of the MC_CamIn function block. This input is used to configure how the slave axis is synchronized with the master axis when MC_CamIn is started.

Basically, there are three possible ways:

  • The slave axis immediately follows the trajectory specified by the cam and the master axis. Depending on the start status of the slave axis, this can lead to a jump in position, velocity, and/or acceleration of the slave axis.

    StartMode: absolute, relative

  • The slave axis synchronizes as quickly as possible while maintaining the predefined velocity, acceleration, deceleration, and jerk limits. 

    StartMode: ramp_in, ramp_in_pos, ramp_in_neg

  • A master position is specified in the cam where the slave axis should follow the trajectory as specified by the cam and the master axis. Synchronization takes place over a configurable distance from the master axis.

    StartMode: ramp_in_dist

For more information about the MC_CamIn function block, see: MC_CamIn (FB)

Structure of the application

The application consists of a PLC_PRG program and a Trace. Moreover, there are four virtual axes: the master axis Master and the three slave axes SlaveAbsolute, SlaveRampIn, and SlaveRampInDist. And there is the cam Cam.

In the PLC_PRG program, three instances of MC_CamIn are executed with the StartMode input set differently:

  • ciSlaveAbsolute with StartMode = absolute

  • ciSlaveRampIn with StartMode = ramp_in

  • ciSlaveRampInDist with StartMode = ramp_in_dist

The function block instances control the corresponding virtual axes SlaveAbsolute, SlaveRampIn, and SlaveRampInDist. The master axis is moved at a constant velocity using an MC_MoveVelocity instance.

The trajectories of the three slave axes and the Active and InSync outputs of the MC_CamIn instances can be tracked in the trace.

All MC_CamIn instances are started when the master axis exceeds position 40:

  • The SlaveAbsolute axis immediately jumps to the set values defined from the cam. The corresponding MC_CamIn instance is immediately Active and InSync.

  • The SlaveRampIn axis synchronizes while maintaining the commanded dynamic limits. The corresponding MC_CamIn instance is immediately Active. From master position ~114, the slave axis follows the trajectory specified by the cam and the master axis and the MC_CamIn instance reports InSync.

  • The SlaveRampInDist axis first remains stationary until the master axis has approached the MasterSyncPosition of 120 up to the MasterStartDistance of 60 configured on the MC_CamIn instance. Then synchronization begins and the MC_CamIn instance reports Active. When the master axis reaches the MasterSyncPosition of 120, the slave axis follows the trajectory specified by the cam and the master axis and the MC_CamIn instance reports InSync.

Commissioning

  1. Build the application and download it to a controller.

  2. Start the trace and the application.

  3. In the trace, you can track the movement of the virtual axes.